//Life Simulation Calendar Header File
//Defines a calendar and functions to access it
//Jeffrey Denton	November 27, 2010

	//Project Include Files//
#include "Month.h"
	//Windows Include Files//
#include "Windows.h"

class calendar
{
protected:
	month monthList[13];
	int year, month, day, hour, minute;

public:
		//Default Constructor
	calendar()
	{
		SetMonthList();
		year = 2011;
		month = 1;
		day = 1;
		hour = 0;
		minute = 0;
	}
		//Paramterized Constructor
	calendar(int y, int mon, int d, int h, int min)
	{
		SetMonthList();
		year = y;
		month = mon;
		day = d;
		hour = h;
		minute = min;
	}

	//SET FUNCTIONS//
		//Set MonthList
	void SetMonthList()
	{
		monthList[0] = invalid;
		monthList[1] = january;
		monthList[2] = february;
		monthList[3] = march;
		monthList[4] = april;
		monthList[5] = may;
		monthList[6] = june;
		monthList[7] = july;
		monthList[8] = august;
		monthList[9] = september;
		monthList[10]= october;
		monthList[11]= november;
		monthList[12]= december;
	}
		//Set the Year 
	void SetYear(int y)
	{
		year = y;
	}
		//Set the Month
	void SetMonth(int mon)
	{
		month = mon;
	}
		//Set the Day
	void SetDay(int d)
	{
		day = d;
	}
		//Set the Hour
	void SetHour(int h)
	{
		hour = h;
	}
		//Set the Minute
	void SetMinute(int min)
	{
		minute = min;
	}
		//Set the Date
	void SetDate(int y, int mon, int d)
	{
		SetYear(y);
		SetMonth(mon);
		SetDay(d);
	}
		//Set the Time
	void SetTime(int h, int min)
	{
		SetHour(h);
		SetMinute(min);
	}

	//PRINT FUNCTIONS//
		//Print Date   Format = 1:35 January 1, 2011
	void PrintDate(HANDLE hConsole, int x, int y)
	{
		COORD pos = {x,y};
		SetConsoleCursorPosition(hConsole, pos);
		printf("%2d:%2d %9s %2d, %4d",hour, minute, monthList[month].name, day, year);
	}

	void Update(int mins)
	{
		minute += mins;
		while (minute >= 60)
		{
			minute -= 60;
			hour += 1;
			
			if (hour >= 24)
			{
				hour = 0;
				day++;
			}
		}

		if (day > monthList[month].numDays)
		{
			if (month <= 11)
			{
				month++;
			}
			
			else
			{
				month = 1;
				year++;
			}

			day = 1;
		}
	}
	
};